﻿<!DOCTYPE html>

<html class="um landscape min-width-240px min-width-320px min-width-480px min-width-768px min-width-1024px">

<head>

    <title></title>

    <meta charset="utf-8">

    <meta name="viewport" content="target-densitydpi=device-dpi, width=device-width, initial-scale=1, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">

    <link rel="stylesheet" href="css/ui-res.css">

    <link rel="stylesheet" href="css/ui-box.css?v=202021">

    <link rel="stylesheet" href="css/ui-base.css?v=202021"> 

    <link rel="stylesheet" href="css/ui-position.css?v=202021">

    <link rel="stylesheet" href="css/ui-img.css?v=202021">

    <link rel="stylesheet" href="css/ui-color.css?v=202021">

    <link rel="stylesheet" href="css/ui-input.css?v=202021">

    <link rel="stylesheet" href="css/iBox.css?v=202021">

   <link rel="stylesheet" href="css/ensureNode.css?v=202021">

    

    <script src="js/zy_control.js"></script>

    <script src="js/zy_click.js"></script> 

    <script src="js/zy_json.js"></script>

    <script src="js/appcan.min.js"></script>

    <script src="js/iBox.js?v=202022"></script>

    <script src="js/main1.js"></script>
<script src="js/common.js"></script>
</head>

<body class="um-vp es-bg" ontouchstart>

  <div class="ub ub-ver">

    <!--块容器开始-->

    <div class="nodeTop" id="nTop">

        <div class="dv1">

            <div>机号</div>

            <div class="dp"  id="jh">-</div>

        </div>

        <div class="dv1">

            <div>机型</div>

            <div class="dp" id="jx">-</div>

        </div>

        <div class="dv1">

            <div>机位</div>

            <div class="dp" id="jw">-</div>

        </div>

        <div class="dv2">

            <div>进港旅客人数</div>

            <div class="dp">-</div>

        </div>

    

    </div>

    

    <div class="nodeMid" id="nMid">

        <table class="nodeMidTable" width="100%">

            <tr>

              <td>节点名称</td>

              <td>开始时间</td>

              <td>结束时间</td>

            </tr>   

        </table>

    </div>

    

    <div class="nodeBody es-bg " id="createtable" style="overflow:auto;width: 99%;">

    </div>  

</div> 

    

</body>

<script>

zy_init();

var rPath="http://hccess.ceair.com/HubManagerWebService/HubManagerWebService.asmx";

//时区处理

window.localStorage.setItem("myTimezone","8");

 function calcTime(ggtime){

     var ystime=ggtime;

     console.log("beforedata:"+ggtime);

     var offset=window.localStorage.getItem("myTimezone_df");

     if(ggtime==""){

     }else{ 

         if(ggtime.split(' ')[2]=="PM"){ 

             var hms=trasTime(ggtime.split(' ')[1]);

             ggtime=ggtime.split(' ')[0].split("/")[2]+"/"+ggtime.split(' ')[0].split("/")[0]+"/"+ggtime.split(' ')[0].split("/")[1]+" "+hms;

              var d = new Date(ggtime); 

             var utc = d.getTime() + (d.getTimezoneOffset() * 60000);  

             var nd = new Date(utc + (3600000*offset));

             ggtime=(nd+"").split(" ")[3]+"-"+(nd+"").split(" ")[2]+"-"+(nd+"").split(" ")[0]+" "+(nd+"").split(" ")[4];

             console.log("gh:"+ggtime);

             return (nd+"").split(" ")[4];

         }else if(ggtime.split(' ')[2]=="AM"){

             ggtime=ggtime.split(' ')[0].split("/")[2]+"/"+ggtime.split(' ')[0].split("/")[0]+"/"+ggtime.split(' ')[0].split("/")[1]+" "+ggtime.split(' ')[1]

              var d = new Date(ggtime); 

             var utc = d.getTime() + (d.getTimezoneOffset() * 60000);  

             var nd = new Date(utc + (3600000*offset));

             ggtime=(nd+"").split(" ")[3]+"/"+(nd+"").split(" ")[2]+"/"+(nd+"").split(" ")[0]+" "+(nd+"").split(" ")[4];

             console.log("gh:"+ggtime);

             return (nd+"").split(" ")[4];

         }else{

             ggtime=ggtime.split(' ')[0].split("-")[0]+"/"+ggtime.split(' ')[0].split("-")[1]+"/"+ggtime.split(' ')[0].split("-")[2]+" "+ggtime.split(' ')[1];

             var d = new Date(ggtime); 

             var utc = d.getTime() + (d.getTimezoneOffset() * 60000);  

             var nd = new Date(utc + (3600000*offset));

             ggtime=(nd+"").split(" ")[3]+"-"+(nd+"").split(" ")[2]+"-"+(nd+"").split(" ")[0]+" "+(nd+"").split(" ")[4];

             console.log("gh:"+ggtime);

             if((nd+"").split(" ")[4]==undefined){

                 if(ystime.split(" ")[1]==undefined){

                     return ystime;

                 }else{

                     return ystime.split(" ")[1];

                 }

             }else{

                 return (nd+"").split(" ")[4];

             }

         }

     } 

} 



var key='';

var Hg;//列表高度

window.uexOnload=function(type){

        if(!type){

            key=getLocVal("Key");

            var nodeTop=$$("nTop").offsetHeight;

            var nodeMid=$$("nMid").offsetHeight;

            var bodyH = document.body.clientHeight;

            Hg=bodyH-nodeTop-nodeMid-50;

            getTasks();

            //alert(calcTime("8/13/2016 4:36:33 AM"))

             uexWindow.toast('0', '5', '正在加载请稍后....', 0);

        }

    }

    function getTasks()

    {   

        var fttype=window.localStorage.getItem("fttype");

        var url=yddfProUrl+"system_getHbrw.action";

        console.log(key); 

        //key="87001628@info$MU5189#2016-09-13 04:40:00";

        var idata =[{'key':'key','type':'0','value':key},{'key':'type','type':'0','value':fttype}];

        $.getJSON(url, function(json){ 

             uexWindow.closeToast();

//			 console.log(json)

                GetData(json);

        }, "json",function(err){

            alert(err);

                }, "POST",idata,false);

    }

  function GetData(data)

  {

                    var strx='';

                    strx+='<table style="word-break:break-all; word-wrap:break-word;background-color:rgba(255,255,255,.4)">';

                    var jh =data.jh==''?'-': data.jh;

                    var jx =data.jx==''?'-': data.jx;

                    var jw=data.jw==''?'-':data.jw;

                    $$("jh").innerHTML=jh;

                    $$("jx").innerHTML=jx;

                    $$("jw").innerHTML=jw;

                    var tempJson=data.rw;

                    len=tempJson.length;

                    var htmlbb="";

					console.log(tempJson);

                     for(var i=0;i<len;i++)

                    {

                        

                        var TASKID = tempJson[i].TASKID;

                        var TASKTYPE = tempJson[i].TASKTYPE;

                        var TASKNAME = tempJson[i].TASKNAME;

                        TASKNAME=getTaskNameCHN(TASKNAME);

                        var SCHEDULEDSTARTTIME =tempJson[i].SCHEDULEDSTARTTIME;   //格式：10/22/2015 9:39:00 AM

                        var SCHEDULEDENDTIME = tempJson[i].SCHEDULEDENDTIME;

                        var ACTUALSTARTTIME = tempJson[i].ACTUALSTARTTIME;

                        var lb_ACTUALSTARTTIME=tempJson[i].ACTUALSTARTTIME;

                        var lb_ACTUALENDTIME=tempJson[i].ACTUALENDTIME;

                        lb_ACTUALSTARTTIME=calcTime(lb_ACTUALSTARTTIME);

                        lb_ACTUALENDTIME=calcTime(lb_ACTUALENDTIME);

                        var lb_ACTUALTIME=tempJson[i].ACTUALTIME;

                        lb_ACTUALTIME=calcTime(lb_ACTUALTIME);

                        

                        if(ACTUALSTARTTIME.length>0)

                        {

                            if(ACTUALSTARTTIME.split(' ')[2]=='PM')

                            {

                                ACTUALSTARTTIME=trasTime(ACTUALSTARTTIME.split(' ')[1]);

                            }

                            else{

                                    ACTUALSTARTTIME=ACTUALSTARTTIME.split(' ')[1];

                            }

                            

                        }

					

                        var ACTUALENDTIME = tempJson[i].ACTUALENDTIME;

                        console.log("ACTUALENDTIME"+ACTUALENDTIME);

                        if(ACTUALENDTIME.length>0)

                        {

                            if(ACTUALENDTIME.split(' ')[2]=='PM')

                            {

                                ACTUALENDTIME=trasTime(ACTUALENDTIME.split(' ')[1]);

                            }

                            else{

                                    ACTUALENDTIME=ACTUALENDTIME.split(' ')[1];

                            }

                        }

						

                        var SCHEDULEDTIME = tempJson[i].SCHEDULEDTIME;

                        var ACTUALTIME =tempJson[i].ACTUALTIME;

                        if(ACTUALTIME.length>0)

                        {

                            if(ACTUALTIME.split(' ')[2]=='PM')

                            {

                                ACTUALTIME=trasTime(ACTUALTIME.split(' ')[1]);

                            }

                            else{

                                    ACTUALTIME=ACTUALTIME.split(' ')[1];

                            }

                        }

                        var TASKSTATUS = tempJson[i].TASKSTATUS;

                        var ISSYSTEM = tempJson[i].ISSYSTEM;

                        

                        var TASKRECEIVETIME = tempJson[i].TASKRECEIVETIME;

                        var TASKREADYTIME = tempJson[i].TASKREADYTIME;

                        var Time=tempJson[i].sj;   //格式：2015-10-22 09:37:00

                        Time=Time.split(" ")[0];

                        

						 var BtnStart='<div id="STARTTIME_'+TASKID+'" class="recordBtn" onclick="recordClick(\'STARTTIME_'+TASKID+'\',\'' +TASKTYPE+ '\',\'' +ACTUALSTARTTIME+ '\',\'' +ACTUALENDTIME+ '\',\'' +TASKRECEIVETIME+ '\',\'' +TASKREADYTIME+ '\',\'' +ACTUALTIME+ '\',\'' +Time+ '\')">记 录</div>';

    

var BtnEnd='<div id="ENDTIME_'+TASKID+'" class="recordBtnDisabled">记 录</div>';

var BtnEnd2='<div id="ENDTIME_'+TASKID+'" class="recordBtn" onclick="recordClick(\'ENDTIME_'+TASKID+'\',\'' +TASKTYPE+ '\',\'' +ACTUALSTARTTIME+ '\',\'' +ACTUALENDTIME+ '\',\'' +TASKRECEIVETIME+ '\',\'' +TASKREADYTIME+ '\',\'' +ACTUALTIME+ '\',\'' +Time+ '\')">记 录</div>';    

						

						 var isAuto=false;

						 if(ISSYSTEM=="1")

						 {

						 	isAuto=true;

						 }

						  var str0='';

						    var str1='';

							  var str2='';

							 if(TASKTYPE=='ACTIVITY')

							{

								if(isAuto)

								{    

									 str0+='<div class="time autoColor clickenable uc-tbr uc-tbl" onclick="taskNameClick(\''+SCHEDULEDSTARTTIME+'\',\'' +SCHEDULEDENDTIME+ '\')">'+TASKNAME+'</div>';

								}else{

									 str0+='<div class="time clickenable uc-tbr uc-tbl" onclick="taskNameClick(\''+SCHEDULEDSTARTTIME+'\',\'' +SCHEDULEDENDTIME+ '\')">'+TASKNAME+'</div>';

								}

							}else

							{

								if(isAuto)

								{

									 str0+='<div class="time autoColor">'+TASKNAME+'</div>';

								}else{

									 str0+='<div class="time">'+TASKNAME+'</div>';

								}

							}

							

							/////

							if(isAuto)     //自动

									{

										if(TASKTYPE=='ACTIVITY')

                                        {

                                            if(ACTUALSTARTTIME!='') 

                                            {

                                                str1+='<div class="time">'+lb_ACTUALSTARTTIME+'</div>';

                                            }else{

												str1+='<div class="time">'+'-'+'</div>';

											}

                                        }else{

											 str1+='<div class="time">'+''+'</div>';

										}

									}

									else{     //手动

										if(TASKTYPE=='ACTIVITY')

                                        {

											if(ACTUALSTARTTIME!='')

                                            {

                                                str1+='<div class="time">'+lb_ACTUALSTARTTIME+'</div>';

                                            }else{

												str1+=BtnStart;

											}

                                        }else{

											 str1+='<div class="time">'+''+'</div>';

										}

									}

						/////////////

						if(isAuto)     //自动

						{

							if(TASKTYPE=='ACTIVITY')

                            {

                                if(ACTUALENDTIME!='')

                                {

                                    str2+='<div class="time">'+lb_ACTUALENDTIME+'</div>';

                                }else{

									str2+='<div class="time">'+'-'+'</div>';

								}

                            }else{

								 if(ACTUALTIME!='')

                                {

                                    str2+='<div class="time">'+lb_ACTUALTIME+'</div>';

                                }else{

									str2+='<div class="time">'+'-'+'</div>';

								}

							}

						}

						else{     //手动

							if(TASKTYPE=='ACTIVITY')

                            {

								if(ACTUALENDTIME!='')

                                {

                                    str2+='<div class="time">'+lb_ACTUALENDTIME+'</div>';

                                }else{

									if(ACTUALSTARTTIME!='')

									{

										str2+=BtnEnd2;

									}else{

										str2+=BtnEnd;

									}

								}

                            }else{

								 if(ACTUALTIME!='')

                                {

                                    str2+='<div class="time">'+lb_ACTUALTIME+'</div>';

                                }else{

									str2+=BtnEnd2;

								}

							}

						}

						////////

                         htmlbb+='<div style="width: 99%;display: -webkit-box;border: 1px solid gray;text-align: center;line-height: 1.62em;background: rgba(255,255,255,.3)" >'

                             +'<div style="width:33.3%;border-right: 1px solid gray;line-height:1.62em" >'+str0+'</div>'

                             +'<div class="ub ub-ac ub-pc" style="width: 33.3%;border-right: 1px solid gray" >'+str1+'</div>'

                             +'<div class="ub ub-ac ub-pc" style="width: 33.3%" >'+str2+'</div>'

                             +'</div>'

                    }

                   

					 document.getElementById("createtable").innerHTML=htmlbb;

  }

 

 function taskNameClick(starttime,endtime)

 {

    //starttime=timeHandler(starttime);

    //endtime=timeHandler(endtime);

    starttime=calcTime(starttime);

    endtime=calcTime(endtime);

    if(starttime!=null&&endtime!=null)

    {

        var str="计划开始时间："+starttime+" \n计划结束时间："+endtime;

        uexWindow.alert('提示信息',str,'确定');

    }

 }

 

function timeHandler(timeStr)

{

    if(timeStr.length>0)

    {

        if(timeStr.split(' ')[2]=='PM')

        {

            timeStr=trasTime(timeStr.split(' ')[1]);

        }

        else{

                timeStr=timeStr.split(' ')[1];

        }

        return timeStr;

    }else

    {

        return null;

    }

    

}

 function recordClick(id,TASKTYPE,ACTUALSTARTTIME,ACTUALENDTIME,TASKRECEIVETIME,TASKREADYTIME,ACTUALTIME,Time){

            var win =  appcan.require('window'); 

            win.confirm({

                title:'提示',

                content:'确定记录任务吗？',

                buttons:['确定','取消'],

                callback:function(err,data,dataType,optId){

                   if(data==0) 

                   {

                        getServiceTime(id,TASKTYPE,ACTUALSTARTTIME,ACTUALENDTIME,TASKRECEIVETIME,TASKREADYTIME,ACTUALTIME,Time);

                   }

                }

            });

            

}

/**

 * 获取服务器时间

 */

function getServiceTime(rid,TASKTYPE,ACTUALSTARTTIME,ACTUALENDTIME,TASKRECEIVETIME,TASKREADYTIME,ACTUALTIME,Time)

{

    var arr=rid.split("_");

    var id=arr[1];

    var btntype=arr[0];    //是开始or结束按钮



	var url =yddfProUrl+"hbrw_getServiceTime.action";

      uexWindow.toast('0', '5', '记录中....', 0);

    $.getJSON(url, function(xml){

//		console.log(xml)

				 uexWindow.closeToast();

                    var servicetime=xml;

                    var changedTime=xml.split('">')[1].substr(0,19);  //记录的时间包括日期

                    var lb_changedTime=calcTime(changedTime);

                    var str='<div class="time">'+lb_changedTime+'</div>';

                    //var str='<div class="time">'+xml.split('-')[3].split(' ')[1]+'</div>';

                    

                    $$(rid).parentNode.innerHTML = str;

                     console.log("changedTime"+changedTime)

                    var rctime=changedTime.split(' ')[1]; //记录的时间只含时间

                    if(btntype=='STARTTIME'&&TASKTYPE=="ACTIVITY")

                    {

                        var endId="ENDTIME_"+id;

                    $$(endId).className='recordBtn';

                    $$(endId).id=endId;

                    $$(endId).onclick = function(){

                                    recordClick(this.id,TASKTYPE,ACTUALSTARTTIME,ACTUALENDTIME,TASKRECEIVETIME,TASKREADYTIME,ACTUALTIME,Time);

                    }

//                        recordTime(id,rctime,ACTUALENDTIME);

                    }

                    else{

//                        recordTime(id,ACTUALSTARTTIME,rctime);

                    }                       

                    UpdateTaskTime(id,TASKTYPE,changedTime,btntype,getLocVal("uname"));  

                    

    }, "xml",function(err){

        alert(err);

            }, "POST", "");

}



/**

 * 记录更新时间  目前能提供修改的字段中若TaskType =ACTIVITY有四个字段名称actualstarttime，actualendtime，taskreceivetime，taskreadytime,TaskType =EVENT有一个字段名称actualtime

 */

function UpdateTaskTime(id,TASKTYPE,changedTime,btntype,username)

{

	

    var url=yddfProUrl+"hbrw_deal.action?";

    var para="";

    if(TASKTYPE=="ACTIVITY")

    {

        if(btntype=='STARTTIME')

        {

            para="actualstarttime|"+changedTime;

        }else

        {

            para="actualendtime|"+changedTime;

        }

    }else

    {

        para="actualtime|"+changedTime;

    }

    console.log("key:"+key+"--id"+id+"--TASKTYPE"+TASKTYPE+"--para"+para)

var idata =[{'key':'key','type':'0','value':key}, {'key':'Taskid','type':'0','value':id}, {'key':'TaskType','type':'0','value':TASKTYPE}, {'key':'paras','type':'0','value':para},{'key':'userid','type':'0','value':'55'}, {'key':'username','type':'0','value':username}];

    $.getJSON(url, function(xml){

//          alert("传参："+para+"/传参地址url: "+url+"/返回值："+xml);

    }, "xml",function(err){

        alert(err);

            }, "POST",idata,false);

}

/**

 * 时间格式为：10/22/2015 9:51:00 AM

 * @param {Object} timeStr

 */

function timeHandle(time,timeStr){

    var tstr=timeStr.replace(/^\'|\'$/g,"");

    var time=time.replace(/^\'|\'$/g,"");

    if(timeStr.length>10&&timeStr!=''&&timeStr!="")

    {

        var arr=tstr.split(" ");

        return time+" "+arr[1];

    }

    return time+" ";

}

/**

 * 判断任务是否不能人工，只能自动生成true 为自动，不能手动记录

 * @param {Object} taskname

 */

function isAutoByTaskName(tasknameCHN)

{

     switch (tasknameCHN)

        {

            case "落地":

            case "滑入":

            case "上轮档":

            case "开货舱门":

            case "推出":

            case "起飞":

            case "关客舱门":

            case "关货舱门":

            case "开舱门":

            case "撤轮档":

                return true;

            break;  

            case "污水":

            case "清水":

            case "加油":

            case "撤桥梯":

            case "下客":

            case "货运卸":

            case "平衡单上传":

            case "机组到位":

            case "配餐":

            case "首件行李":

            case "值机关闭":

            case "货物到位":

            case "通知登机":

            case "分拣交接":

            case "末件行李":

            case "装机":

            case "登机":

            case "滑出":

                return false;

            break;

            default: return false;break;

        }

}

/**

 * 时间由服务器返回的12制转24制

 * @param {Object} time

 */

function trasTime(time)

{

    var arr=time.split(':')

    var h=parseInt(arr[0])+12;

    var m=arr[1];

    var s=arr[2];

    return h+":"+m+":"+s;

}



/**

 * 时间本地记录:页面重新加载记录的值被重置回未记录状态，先本地存储

 *  * @param {Object} time1:开始时间，time2:结束时间

 */

var jsonstr="{\"array\":[";

function recordTime(TASKID,time1,time2)

{

    var recObj=strToJson(localStorage.getItem("recordTime"));

    if(recObj!=null&&recObj!=undefined&&recObj!='undefined')

    {

//        jsonstr="{\"array\":[";

        for(var i=0;i<recObj.array.length;i++)

        {

            var obj=recObj.array[i];

			if(obj.TASKID==TASKID)

			{

					if(time1!='')

					{

						obj.time1=time1;

					}

					if(time2!='')

					{

						obj.time2=time2;

						alert(obj.time2)

					}

			}

           

        }

		

    }

   	if(recObj!=null)

	{

		jsonstr=JSON.stringify(recObj).substring(0,jsonstr.length-4);

	}

	 console.log("/// "+jsonstr);

   	 jsonstr += "{\"TASKID\""+":\"" + TASKID  + "\",";

     jsonstr += "\"time1\""+":\"" + time1  + "\",";

     jsonstr += "\"time2\""+":\"" + time2  + "\"";

    

 

    jsonstr += "}]}";

   console.log("--"+jsonstr);

    setLocVal("recordTime",jsonstr);

}

/**

 * 获取记录过的时间值

 */

function getRecordTime(TASKID)

{

    var recObj=strToJson(getLocVal("recordTime"));

    if(recObj!=null&&recObj!=undefined&&recObj!='undefined')

    {

        for(var i=0;i<recObj.array.length;i++)

        {

            var obj=recObj.array[i];

            if(obj.TASKID==TASKID)

            {

                return  obj.time1+"|" +obj.time2;

            }

        }

    }

    return "|";

}

function strToJson(str){ 

    var json = eval('(' + str + ')'); 

    return json; 

}

/**

 * 任务名称中英文对照

 * @param {Object} taskname

 */

function getTaskNameCHN(taskname)

{

     switch (taskname)

        {

            case "arrive": return "落地";break;

            case "taxi": return "滑入";break;

            case "on_block": return "上轮档";break;

            case "lavetory_service_arrival": return "污水";break;

            case "water_service": return "清水";break;

            case "fuelling": return "加油";break;

            //case "air_bridge": return "客梯车";break;

            case "cargo_door_open": return "开货舱门";break;

            case "carbin_door_open": return "开舱门";break;

            case "deboarding": return "下客";break;

            case "unloading": return "货运卸";break;

            case "load_sheet_in_cockpit": return "平衡单上传";break;

            case "crew_on_board": return "机组到位";break;

            case "catering": return "配餐";break;

            case "first_bag": return "首件行李";break;

            case "checkin_counter_closed": return "值机关闭";break;

            case "cargo_on_site": return "货物到位";break;

            case "notice_to_boarding": return "通知登机";break;

            case "end_bag_sorting": return "分拣交接";break;

            case "last_bag": return "末件行李";break;

            case "load": return "装机";break;

            case "carbin_door_closed": return "关客舱门";break;

            case "boarding": return "登机";break;

            case "cargo_door_closed": return "关货舱门";break;

            case "offblocks": return "撤轮档";break;

            case "push_back": return "推出";break;

            case "taxi_out": return "滑出";break;

            case "depart": return "起飞";break;

			

			case "carbin_clean": return "客舱清洁";break;

			case "flight_inspection": return "航班督查";break;

			case "carbincrew_on_board": return "乘务登机";break;

			case "trailer": return "拖车到位";break;

			case "release_order": return "放行单上机";break;

			case "release_order_finished": return "放行单完成";break;

			case "load_sheet_finished": return "装机单完成";break;

			case "maintenance_release": return "机务放行";break;

			case "manifest_finished": return "舱单完成";break;

			case "bridge_ladder": return "靠桥梯";break;

            case "car_ferry": return "进港摆渡车";break;

            case "air_bridge": return "撤桥梯";break;

            default: return taskname;break;

        }

}

</script>

</html>